[TOC]
summary: Reason is the light and the light of life.
toc: show
None
在对应位置增加一个维度(类似于unsqueeze(axis=)
)
...
等价于[:,:,:]
import numpy as np
arr = np.random.randn(5, 10)
arr.shape
(5, 10)
arr[None, ...].shape
(1, 5, 10)
arr[..., None].shape
(5, 10, 1)
arr[:, None, :].shape
(5, 1, 10)
arr[None, ...] == arr[None, :, :]
array([[[ True, True, True, True, True, True, True, True, True,
True],
[ True, True, True, True, True, True, True, True, True,
True],
[ True, True, True, True, True, True, True, True, True,
True],
[ True, True, True, True, True, True, True, True, True,
True],
[ True, True, True, True, True, True, True, True, True,
True]]])